<%@page import="entity.Page"%>
<%@page import="entity.Users"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户数据</title>
</head>
<body>
<h1>用户数据</h1>
<script type="text/javascript" src="/MVC_Test1/JS/jquery.min.js"></script>
<script type="text/javascript">
	var page_index=$("#PageIndex").val();
	$(document).ready(function() {
		$("tr:odd").css("background-color","lightgrey");
	});
	$.ajax({
		type:"post",
		dataType:"json",
		url:"ALL-Data",
		data:{"page_index":page_index},
		success:function(data){
			
		}
	})
</script>
<table border="black">
	<th>UID</th>
	<th>UNAME</th>
	<th>UPWD</th>
	<th>操作</th>
	<a href="/MVC_Test1/User_admin/UserAdd.jsp">增加</a><br/>
	<% Page pagec=(Page) request.getAttribute("page");
		for(Users users:pagec.getUsers()){
	%>
		<tr>
			<td><%=users.getUID() %></td>
			<td><%=users.getUName() %></td>
			<td><%=users.getUPWD() %></td>
			<td>
			<a href="/MVC_Test1/UserUpdate?UID=<%=users.getUID()%>">修改</a>
			<a href="/MVC_Test1/UserDelete?UID=<%=users.getUID() %>">删除</a>
			</td>
		</tr>
	<%
	}
	%>
		<tr>
		<% if(pagec.getCurrentpage()==1){
			%>
		<a href="QueryByPage?pageindex=<%=pagec.getCurrentpage()+1 %>">下一页</a>
		<a href="QueryByPage?pageindex=<%=pagec.getTotalpage() %>">尾页</a>
		<% 	
		}
		if(pagec.getCurrentpage()==pagec.getTotalpage()){
			%>
		<a href="QueryByPage?pageindex=1">首页</a>
		<a href="QueryByPage?pageindex=<%=pagec.getCurrentpage()-1 %>">上一页</a>
		<%
		}else if(pagec.getCurrentpage()!=1&& pagec.getCurrentpage()!=pagec.getTotalpage()){
		%>
		<a href="QueryByPage?pageindex=1">首页</a>
		<a href="QueryByPage?pageindex=<%=pagec.getCurrentpage()-1 %>">上一页</a>
		<a href="QueryByPage?pageindex=<%=pagec.getCurrentpage()+1 %>">下一页</a>
		<a href="QueryByPage?pageindex=<%=pagec.getTotalpage() %>">尾页</a>
		<%			
		}
		out.print(pagec.getCurrentpage());
		out.print(pagec.getTotalpage());
		%>
		</tr>
</table>
<a href="/MVC_Test1/Main_page.jsp">返回主页</a>
</body>
</html>